<?php
namespace Test\Controller;
use Think\Controller;
class IndexController extends Controller {
    public function _initialize(){
        header('Access-Control-Allow-Origin:*');
        header('Access-Control-Allow-Methods:GET');
        header('Access-Control-Allow-Methods:POST');
        header('Access-Control-Allow-Headers:x-requested-with,content-type');
    }

    /**
     * 测试题 测试人数+1
     * 返回数据
     */
    public function index(){
        M('retimes')->where(['id'=>1])->setInc('testtimes');
        $topic=M('topictest')->order('id asc')->select();
        $return_topic["code"] = '1';
        if(count($topic) == 0){
            $return_topic["code"] = '-1';
        }else{
            $return_topic["value"] = $topic;
        }
//        for($i=0;$i<count($return_topic['value']);$i++)
//        {
//            $info[]= array(
//                "id" => $return_topic['value'][$i]['id'],
//                "topic" => $return_topic['value'][$i]['topic'],
//                "option" => array(
//                    $return_topic['value'][$i]['option1'],
//                    $return_topic['value'][$i]['option2'],
//                    $return_topic['value'][$i]['option3']
//                )
//            );
//
//        }
        echo json_encode($return_topic,JSON_UNESCAPED_UNICODE);
    }

    //分享页面1
    public function test(){
        $this->display();
    }
    //分享页面2
    public function test2(){
        $this->display();
    }
    //护工分享页面
    public function person(){
        $this->display();
    }
    //小组分享页面
    public function group(){
        $this->display();
    }
    //诊所帖子分享页面
    public function clinicTie(){
        $this->display();
    }
    //banner页跳转
    public function banner(){
        $this->display();
    }
    //banner页跳转
    public function banner59(){
        $this->display();
    }
    //banner页跳转
    public function zhaopin(){
        $this->display();
    }
    //banner页跳转
    public function jujia(){
        $this->display();
    }
    //banner页跳转
    public function lvyou(){
        $this->display();
    }
    //分享获取护工信息
//    public function getFindMessage($fakeid){
//        $flag = substr($fakeid,0,1);//A护工  B小组  C诊所
//        $id = substr($fakeid,4);
//        switch ($)
//    }

    /**
     * 图片上传测试
     * @param $name
     */
    public function areUploadImg($name){
        $url = upload($name);
        echo $url;
    }

    /**
     * 发送邮件测试
     */
    public function setEmail(){
        sentEmail('909012321@qq.com','中风医馆|店铺审核','http://www.chinaola.net/ola/');
    }

    /**
     * out_trade_no、body、total_fee、trade_type
     */
    public function weixin(){
        $this->value = [
            'out_trade_no'=>'abc',
            'body'=>'asd',
            'total_fee'=>'1',
            'trade_type'=>'APP',
        ];
        vendor('Wxpay.WxPayApi');
        $wx = \WxPayApi::unifiedOrder($this->value);
        var_dump($wx);
    }
}
